<?php
$this->Html->addCrumb('Companies', '/admin/companies');
$this->Html->addCrumb('Add');
?>
<?php 
$this->Html->scriptStart(array('inline' => false));
echo '
      $(function(){
        $("#CompanyAdminAddForm").TWS_Form( {
          validate : {
          rules : {
            CompanyServiceId : {required : true, help : "This is the type of service that the company is associated with."},
            CompanyName : {required : true, help : "This is the name of the company"},
            CompanyDescription : {required : true, help : "A bio of the company or description of the goods and services that are provided by the company"},
            CompanyPhone: {phoneUS : true},//TODO - validate T&T Phone
            CompanyPhoneAdditional: {phoneUS : true},
            CompanyEmail : {email : true},
            CompanyUrl : {url : true},
            CompanyFacebookUrl : {url : true},
            CompanyTwitterUrl : {url : true},
            CompanyPinterestUrl : {url : true}
          }
          }});
        });
       ';
$this->Html->scriptEnd();
?>
<h1>Add Company</h1>

<?php echo '<div id="actionLink">'.$this->Html->link('Back to list of Companies',array('action'=>'index','admin'=>true)).'</div>'; ?>

<?php echo $this->element('errors', array('errors' => isset($errors)? $errors : null)); ?>
<?php

echo $this->TWSForm->create('Company',  array(
    'inputDefaults' => array(
        'div' => array('class'=>'row')),
        'class'=>'inlineForm',
        'type'=>'file'));
echo $this->TWSForm->input('service_id', array('name'=>'CompanyServiceId', 'type'=>'select', 'label'=>'<span class="required">*</span>Service', 'options'=>$options));
echo $this->TWSForm->input('name', array('name'=>'CompanyName', 'size'=>'63', 'type'=>'text', 'label'=>'<span class="required">*</span>Name'));
echo $this->TWSForm->input('description', array('rows'=>'5','cols'=>'60','name'=>'CompanyDescription'));
echo $this->TWSForm->input('address', array('rows'=>'5','cols'=>'60','name'=>'CompanyAddress'));
echo $this->TWSForm->input('phone', array('name'=>'CompanyPhone', 'type'=>'tel'));
echo $this->TWSForm->input('phone_additional', array('name'=>'CompanyPhoneAdditional', 'type'=>'tel', 'label'=>'Additional phone'));
echo $this->TWSForm->input('fax', array('name'=>'CompanyFax', 'type'=>'tel'));
echo $this->TWSForm->input('email', array('name'=>'CompanyEmail', 'type'=>'text'));
echo $this->TWSForm->input('url', array('name'=>'CompanyUrl', 'type'=>'text'));
echo $this->TWSForm->input('facebook_url', array('name'=>'CompanyFacebookUrl', 'type'=>'text', 'label'=>'Facebook url'));
echo $this->TWSForm->input('twitter_url', array('name'=>'CompanyTwitterUrl', 'type'=>'text', 'label'=>'Twitter url'));
echo $this->TWSForm->input('pinterest_url', array('name'=>'CompanyPinterestUrl', 'type'=>'text', 'label'=>'Pinterest url'));
echo $this->TWSForm->input('image_path', array('type'=>'file', 'label'=>'Upload image', 'name'=>'CompanyImagePath'));
echo $this->TWSForm->end( array("label"=>"Add", "class"=>"button"));


?>